package com.lianjinsu.shop.core.configuration;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class MybatisPlusConfiguration {

    @Component
    static class AdvancedSqlInjector extends DefaultSqlInjector {
        @Override
        public List<AbstractMethod> getMethodList(org.apache.ibatis.session.Configuration configuration, Class<?> mapperClass, TableInfo tableInfo) {
            List<AbstractMethod> oldMethodList = super.getMethodList(configuration, mapperClass, tableInfo);
            List<AbstractMethod> methodList = new ArrayList<>(oldMethodList.size() + 4);
            methodList.addAll(oldMethodList);
            methodList.add(new InsertBatchSomeColumn());
            return methodList;
        }
    }
}
